import { ApiProperty } from '@nestjs/swagger'
import { IsEnum, IsNumber, IsOptional, IsString } from 'class-validator'
import { Column, CreateDateColumn, Entity, PrimaryGeneratedColumn, UpdateDateColumn } from 'typeorm'
import { EEnableStatus } from '@/shared/types/globalEnum'

@Entity('download')
export class Download {
  @PrimaryGeneratedColumn('increment')
  @IsNumber()
  downloadId: number

  /**
   * 下载地址
   */
  @Column()
  @IsString()
  downloadUrl: string

  /**
   * 游戏图片
   */
  @Column({ nullable: true })
  @IsString()
  @IsOptional()
  gameImg?: string

  /**
   * 是否当前使用
   */
  @ApiProperty({ default: EEnableStatus.DISABLED })
  @Column({
    type: 'enum',
    enum: EEnableStatus,
    default: EEnableStatus.ENABLED,
  })
  @IsEnum(EEnableStatus)
  @IsOptional()
  useStatus?: EEnableStatus

  @CreateDateColumn()
  createdAt?: Date

  @UpdateDateColumn()
  updatedAt?: Date
}
